#!/bin/bash
#
# Script to extract and plot the electronic DOS of copper from example 3
# You might need to modify this file if you have a different input/script
#
# Set environment
homedir=$( cd "$( dirname $0 )" && pwd)
. ${homedir}/environment

# Output from band calculation is a must
for ff in DOSCAR
do
if [ ! -s "${ff}" ]; then
   echo "File: ${ff} not found or empty!"
   exit
fi
done

# Extract the band structure information by using vaspkit
cat > .vkit.in << EOF
11
111
EOF
${VKT} < .vkit.in > .vkit.out
# remove intermediate files
rm -rf .vkit.in .vkit.out ITDOS.dat
#
# Script to draw the band structure
cat > .gnuplot.scr << EOF
set term post enha colo 20
set out 'Cu-DOS.eps'

set xlabel 'Energy (eV)'
set ylabel 'DOS'

set format y '%.1f'

set xr [-10:10]
set mxtics 5

unset key
plot 'TDOS.dat' u 1:2 w l t ''

# output a png file
set term png enha trans truec
set out "Cu-DOS.png"
replot

EOF
# gnuplot is employed to draw the figure
gnuplot .gnuplot.scr;  rm -rf .gnuplot.scr

# visualize the figure by using evince
evince Cu-DOS.eps

exit 0
